<?


include "homepages/linkspoty.php";


function description() {
	if (1) {
		display_header();
	}
}


function links_list() { 
	global $portal;
	
	if (1) { ?>
		<small>Explore the images in this website...</small>
		<ul>
		<?
		
		$links = array(
			'/?view=thumbs&order=added&in=d'=>'Recently added thumbnails',
			'/?view=listing'=>'Detailed listing',
			'/statistics.php'=>'Overview Statistics',
			'/breakdown.php'=>'By Year Breakdown',
			'/?opt=byyear4'=>'By Year Thumbnails',
			#'/?view=slide'=>'Slideshow',
			#'/?view=map'=>'Thumbnail Map',
			'/map.php'=>'Coverage Map',
			'/breakdown.php?by=category'=>'Category Breakdown',
			'/breakdown.php?view=cloud&by=category&order=count&in=d'=>'Category Word Cloud',
			#'/breakdown.php?view=text&by=realname&order=count&in=d'=>'Contributor Leaderboard',
			'/search.php'=>'Keyword Search',
			'/related.php'=>'Other Related Portals',
		);#''=>'',
			
		if ($portal['linear_start_id'] > 0) {
			$links['/?order=linear&in=a'] = 'View in linear order';
		}
		
		foreach ($links as $link => $title) {
			print "<li><a href=\"".he($link)."\">".he($title)."</a>";
		}
		
		
		?>
		</ul>
	<? } 
}

function featured_image() { 
	global $portal;

		
	if (empty($portal['featured_id'])) {
		print "Picture coming soon";

	} else {
	
		$c = getRow("SELECT gridimage_id,title,user_id,realname,grid_reference,imagetaken FROM geograph_live.gridimage_search WHERE gridimage_id = {$portal['featured_id']}");
		?>
		
		<div style="padding:5px; text-align:center;background-color:#eeeeee;width:400px;margin-left:auto;margin-right:auto">
			<small>Featured image...</small><br/>
			<a title="view full size image" href="http://www.geograph.org.uk/photo/<? echo $c['gridimage_id']; ?>">
			<img src="<? echo gGUc($c,'full'); ?>" height="240">
			</a><div class="caption"><b><a title="view full size image" href="http://www.geograph.org.uk/photo/<? echo $c['gridimage_id']; ?>"><? echo he($c['title']); ?></a></b> 
			<span class="nowrap">for <a href="/?gridref=<? echo $c['grid_reference']; ?>"><? echo $c['grid_reference']; ?></a>
			by <a title="View profile" href="http://www.geograph.org.uk/profile/<? echo $c['user_id']; ?>"><? echo he($c['realname']); ?></a>
			
			Taken: <?
		  	$bits = explode('-',$c['imagetaken']);
		  	$str = '';
		  	foreach ($bits as $idx => $bit) {
		  		if ($idx > 0) { echo "-"; $str .= '-'; }
		  		$str .= $bit;
		  		print "<a href=\"".linktoself(array('taken'=>$str,'delete'=>'page'))."\">$bit</a>";
		  	} ?>
			</span></div>
		</div>
		<?
	}
} 


function display_images() { 
	global $sql,$opt,$views,$orders,$options;
	global $portal_id,$portal;
	
	setup_defaults();

	customise();

	include($_SERVER['DOCUMENT_ROOT']."/options/{$opt['opt']}.php");

	print "<a href=\"?a\">More listing options...</a>";
	#include($_SERVER['DOCUMENT_ROOT'].'/common/mainstyleselect.inc.php');

	setup_paging();

	if (isset($_GET['a'])) {
		include($_SERVER['DOCUMENT_ROOT'].'/common/accordian.inc.php');
	}

	display_results(); //wrapper around /views/{$opt['view']}.php
}
